home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume10 / xloadimage / patch2 next >
Encoding:
Internet Message Format  |  1990-12-16  |  66.8 KB

  1. Path: uunet!cs.utexas.edu!sun-barr!newstop!exodus!saber.com!jimf
  2. From: jimf@saber.com
  3. Newsgroups: comp.sources.x
  4. Subject: v10i092: xloadimage, Patch2, Part01/01
  5. Message-ID: <4593@exodus.Eng.Sun.COM>
  6. Date: 16 Dec 90 19:24:04 GMT
  7. References: <csx-10i092:xloadimage@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 2203
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: jimf@saber.com
  13. Posting-number: Volume 10, Issue 92
  14. Archive-name: xloadimage/patch2
  15. Patch-To: xloadimage: Volume 10, Issue 48-56, 64
  16.  
  17. This file contains a patch to bring xloadimage version 2.01 up to
  18. version 2.02.
  19.  
  20. Version 2.02 contains the following bug-fixes and enhancements:
  21.  
  22.     * low-level byte order conversion routines have been
  23.       macro-ized for the most common case for dramatic speed
  24.       improvements.
  25.     * -onroot is now compatible with xsetroot.
  26.     * Dithering and halftoning have been sped up somewhat.
  27.     * RLE files now load on MSBFirst machines.
  28.     * Window.c no longer double-paints in some circumstances.
  29.     * Some XWD files that loaded with the wrong colormap will now
  30.       load correctly.
  31.     * G3 FAX files now load and are differentiated from MacPaint
  32.       files.
  33.     * A bug where servers whose depths were not 1 or multiples of
  34.       8 bits would not load images which used the default colormap
  35.       was fixed.  If you had color problems under 2.x and not
  36.       under 1.6, this fixes the problem.
  37.     * The default gamma value was changed to 1.0 as documented.
  38.     * A simple normalization function, -normalize, was added.
  39.     * A grayscale conversion function, -gray, was added.
  40.     * An option to load the root weave, -default, was added.
  41.  
  42. Enjoy,
  43.  
  44. jim frost
  45. saber software
  46. jimf@saber.com
  47.  
  48. -- cut here --
  49. diff -c src.2.01/Makefile src.2.02/Makefile
  50. *** src.2.01/Makefile    Mon Oct  1 14:28:52 1990
  51. --- src.2.02/Makefile    Sat Dec  1 14:38:46 1990
  52. ***************
  53. *** 156,161 ****
  54. --- 156,167 ----
  55.       tar cf xloadimage.tar $(ALL)
  56.       rm Makefile.std
  57.   
  58. + # target for building debuggable versions
  59. + debug:
  60. +     @echo Building a debugging version of xloadimage.
  61. +     make xloadimage CC=$(STD_CC) CFLAGS="-g -DSYSPATHFILE=\\\"$(SYSPATHFILE)\\\""
  62.   # these targets are for those of us who have Saber-C
  63.   
  64.   # load all objects in saber.  useful if you then swap the portions to debug
  65. diff -c src.2.01/README src.2.02/README
  66. *** src.2.01/README    Sun Sep 30 19:08:48 1990
  67. --- src.2.02/README    Sun Dec  2 14:13:04 1990
  68. ***************
  69. *** 156,162 ****
  70.   (gwh@inmos.com) for a geometry patch, Glenn P. Davis
  71.   (davis@unidata.ucar.edu) for McIDAS areafile support, Keith S. Pickens
  72.   (maxwell.nde.swri.edu!ksp) for fixing the RLE loader to work with the
  73. ! updated zio package, and any others whose names I've missed.
  74.   
  75.   HISTORY
  76.   
  77. --- 156,164 ----
  78.   (gwh@inmos.com) for a geometry patch, Glenn P. Davis
  79.   (davis@unidata.ucar.edu) for McIDAS areafile support, Keith S. Pickens
  80.   (maxwell.nde.swri.edu!ksp) for fixing the RLE loader to work with the
  81. ! updated zio package, Mike Douglas (douglas@wilbur.coyote.trw.com) for
  82. ! normalization, Rod Johnson (johnson@wrl.epi.com) for speedup
  83. ! suggestions, and any others whose names I've missed.
  84.   
  85.   HISTORY
  86.   
  87. ***************
  88. *** 224,226 ****
  89. --- 226,245 ----
  90.   The gcc-1-37 make target was fixed to prevent a double-define.  The
  91.   GIF loader was patched to respond better to short GIF files.  The Utah
  92.   RLE image loader was patched to work with the updated ZIO package.
  93. + Version 2.02 added the options -default, -gray, -normalize, and
  94. + -private.  The memToVal routines were macro-ized for substantial speed
  95. + increases.  The atom used for deleting previously allocated colors for
  96. + the -onroot option was changed to correspond to that used by xsetroot.
  97. + Dithering and halftoning were changed to use a lookup table for
  98. + intensities to speed them up somewhat.  Rle.h was changed to use
  99. + memToValLSB() instead of its own byte-swapping algorithm for
  100. + portability.  Window.c was modified to eliminate the initial paint,
  101. + moving it instead to within ConfigureNotify.  A fix was made to xwd.c
  102. + to fix its colormap loader for out-of-order colormaps.  The G3 FAX
  103. + identification function was fixed and the G3 loader moved to prior to
  104. + the MacPaint loader so that both can be used.  A bug in send.c where
  105. + color images using the default colormap would not appear correctly if
  106. + the display depth was not a multiple of 8 was corrected.  The default
  107. + gamma value used in rle.c was changed from 2 to 1.  There were
  108. + miscellaneous portability changes.
  109. diff -c src.2.01/bright.c src.2.02/bright.c
  110. *** src.2.01/bright.c    Sun Sep 30 19:04:11 1990
  111. --- src.2.02/bright.c    Sun Dec  2 13:11:59 1990
  112. ***************
  113. *** 1,6 ****
  114.   /* bright.c
  115.    *
  116. !  * alter an image's brightness by a given percentage
  117.    *
  118.    * jim frost 10.10.89
  119.    *
  120. --- 1,6 ----
  121.   /* bright.c
  122.    *
  123. !  * miscellaneous colormap altering functions
  124.    *
  125.    * jim frost 10.10.89
  126.    *
  127. ***************
  128. *** 11,16 ****
  129. --- 11,19 ----
  130.   #include "copyright.h"
  131.   #include "image.h"
  132.   
  133. + /* alter an image's brightness by a given percentage
  134. +  */
  135.   void brighten(image, percent, verbose)
  136.        Image        *image;
  137.        unsigned int  percent;
  138. ***************
  139. *** 70,75 ****
  140. --- 73,166 ----
  141.       *(image->rgb.blue + a)= gammamap[(*(image->rgb.blue + a))>>8]<<8;
  142.     }
  143.   
  144. +   if (verbose)
  145. +     printf("done\n");
  146. + }
  147. + /* normalize an image.  this was originally written by Michael H. Douglas
  148. +  * to normalize into greyscale and modified by jim frost for color.
  149. +  */
  150. + void normalize(image, verbose)
  151. +      Image        *image;
  152. +      unsigned int  verbose;
  153. + { int          a;
  154. +   Intensity minintensity, maxintensity;
  155. +   float factor;
  156. +   if (! RGBP(image)) /* we're AT&T */
  157. +     return;
  158. +   compress(image, verbose);
  159. +   if (verbose) {
  160. +     printf("  Normalizing image...");
  161. +     fflush(stdout);
  162. +   }
  163. +   /* find range of intensities
  164. +    */
  165. +   maxintensity = 0;
  166. +   minintensity = 65536;
  167. +   for (a= 0; a < image->rgb.used; a++) {
  168. +     if (image->rgb.red[a] > maxintensity)
  169. +       maxintensity = image->rgb.red[a];
  170. +     if (image->rgb.red[a] < minintensity)
  171. +       minintensity= image->rgb.red[a];
  172. +     if (image->rgb.green[a] > maxintensity)
  173. +       maxintensity = image->rgb.green[a];
  174. +     if (image->rgb.green[a] < minintensity)
  175. +       minintensity= image->rgb.green[a];
  176. +     if (image->rgb.blue[a] > maxintensity)
  177. +       maxintensity = image->rgb.blue[a];
  178. +     if (image->rgb.blue[a] < minintensity)
  179. +       minintensity= image->rgb.blue[a];
  180. +   }
  181. +   printf("remapping from %d:%d to 0:65535...", minintensity, maxintensity);
  182. +   fflush(stdout);
  183. +   factor= 65535.0 / (maxintensity - minintensity);
  184. +   for (a= 0; a < image->rgb.used; a++) {
  185. +     image->rgb.red[a]= (float)(image->rgb.red[a] - minintensity) * factor;
  186. +     image->rgb.green[a]= (float)(image->rgb.green[a] - minintensity) * factor;
  187. +     image->rgb.blue[a]= (float)(image->rgb.blue[a] - minintensity) * factor;
  188. + #if 0
  189. +     newrgb = *(image->rgb.red + a);
  190. +     newrgb = ( newrgb - minrgb ) * 65535 / range;
  191. +     *(image->rgb.red + a)= newrgb;
  192. +     *(image->rgb.green + a)= newrgb;
  193. +     *(image->rgb.blue + a)= newrgb;
  194. + #endif
  195. +   }
  196. +   if (verbose)
  197. +     printf("done\n");
  198. + }
  199. + /* convert to grayscale
  200. +  */
  201. + void gray(image, verbose)
  202. +      Image *image;
  203. + { int a;
  204. +   Intensity intensity;
  205. +   if (!RGBP(image))
  206. +     return;
  207. +   if (verbose) {
  208. +     printf("  Converting image to grayscale...");
  209. +     fflush(stdout);
  210. +   }
  211. +   for (a= 0; a < image->rgb.used; a++) {
  212. +     intensity= colorIntensity(image->rgb.red[a],
  213. +                   image->rgb.green[a],
  214. +                   image->rgb.blue[a]);
  215. +     image->rgb.red[a]= intensity;
  216. +     image->rgb.green[a]= intensity;
  217. +     image->rgb.blue[a]= intensity;
  218. +   }
  219.     if (verbose)
  220.       printf("done\n");
  221.   }
  222. diff -c src.2.01/compress.c src.2.02/compress.c
  223. *** src.2.01/compress.c    Sun Sep 30 19:04:12 1990
  224. --- src.2.02/compress.c    Sun Dec  2 13:50:51 1990
  225. ***************
  226. *** 18,28 ****
  227.     unsigned int *used;  
  228.     RGBMap        rgb;
  229.     byte         *pixptr, *pixptr2;
  230. !   unsigned int  a, x, y;
  231.     Pixel         color, newpixlen;
  232.   
  233.     goodImage(image, "compress");
  234. !   if (! RGBP(image)) /* we're AT&T */
  235.       return;
  236.   
  237.     if (verbose) {
  238. --- 18,28 ----
  239.     unsigned int *used;  
  240.     RGBMap        rgb;
  241.     byte         *pixptr, *pixptr2;
  242. !   unsigned int  a, x, y, depth;
  243.     Pixel         color, newpixlen;
  244.   
  245.     goodImage(image, "compress");
  246. !   if (!RGBP(image) || image->rgb.compressed) /* we're AT&T */
  247.       return;
  248.   
  249.     if (verbose) {
  250. ***************
  251. *** 68,90 ****
  252.     freeRGBMapData(&(image->rgb));
  253.     image->rgb= rgb;
  254.   
  255. ! /* Okay, we've compressed the colors, let's do the image */
  256. !   for (y=0,x=1;rgb.used>x;y++) x=x*2;
  257. !   newpixlen = (y / 8) + (y % 8 ? 1 : 0);
  258. !   if (newpixlen < image->pixlen)
  259. !   {
  260. !     if (verbose)
  261. !         printf("  Compressing image...");fflush(stdout);
  262. !     pixptr = image->data; pixptr2 = image->data;
  263. !     for (y= 0; y < image->height; y++)
  264. !      for (x= 0; x < image->width; x++) {
  265. !         valToMem(memToVal(pixptr2,image->pixlen), pixptr, newpixlen);
  266. !         pixptr2 += image->pixlen;
  267. !         pixptr += newpixlen;
  268. !      }
  269. !     image->pixlen = newpixlen;
  270. !     if (verbose)
  271. !         printf("done\n");
  272. !    }
  273.   
  274.   }
  275. --- 68,94 ----
  276.     freeRGBMapData(&(image->rgb));
  277.     image->rgb= rgb;
  278.   
  279. !   /* Okay, we've compressed the colors, let's do the image
  280. !    */
  281.   
  282. +   for (depth=0, x=1; rgb.used > x ; depth++)
  283. +     x= x * 2;
  284. +   newpixlen = (depth / 8) + (depth % 8 ? 1 : 0);
  285. +   if (newpixlen < image->pixlen) {
  286. +     if (verbose)
  287. +       printf("  Compressing image...");fflush(stdout);
  288. +     pixptr = image->data; pixptr2 = image->data;
  289. +     for (y= 0; y < image->height; y++)
  290. +       for (x= 0; x < image->width; x++) {
  291. +     valToMem(memToVal(pixptr2,image->pixlen), pixptr, newpixlen);
  292. +     pixptr2 += image->pixlen;
  293. +     pixptr += newpixlen;
  294. +       }
  295. +     image->pixlen = newpixlen;
  296. +     image->depth= depth;
  297. +     if (verbose)
  298. +       printf("done\n");
  299. +   }
  300. +   image->rgb.compressed= 1;
  301.   }
  302. diff -c src.2.01/copyright.h src.2.02/copyright.h
  303. *** src.2.01/copyright.h    Sun Sep 30 19:04:28 1990
  304. --- src.2.02/copyright.h    Sat Dec  1 14:26:19 1990
  305. ***************
  306. *** 19,24 ****
  307. --- 19,26 ----
  308.    * USE OR PERFORMANCE OF THIS SOFTWARE.
  309.    */
  310.   
  311. + #ifndef __SABER__
  312.   static char *Copyright= "Copyright 1989, 1990 Jim Frost";
  313. + #endif
  314.   #define _JIM_COPYRIGHT_
  315.   #endif
  316. diff -c src.2.01/dither.c src.2.02/dither.c
  317. *** src.2.01/dither.c    Sun Sep 30 19:04:12 1990
  318. --- src.2.02/dither.c    Wed Oct  3 12:06:28 1990
  319. ***************
  320. *** 22,31 ****
  321.   #include "kljcpyrght.h"
  322.   #include "image.h"
  323.   
  324. - #define RedPercent  0.299
  325. - #define GrnPercent  0.587    /* color -> grey conversion parameters */
  326. - #define BluPercent  0.114
  327.   #define MaxIntensity  65536    /* maximum possible Intensity */
  328.   
  329.   #define MaxGrey       32768    /* limits on the grey levels used */
  330. --- 22,27 ----
  331. ***************
  332. *** 90,103 ****
  333.     {
  334.       grey = (unsigned int *)lmalloc(sizeof(unsigned int) * cimage->rgb.used);
  335.       for (i=0; i<cimage->rgb.used; i++)
  336. !     {
  337. !       tmp  = (cimage->rgb.red[i]   * RedPercent);
  338. !       tmp += (cimage->rgb.green[i] * GrnPercent);
  339. !       tmp += (cimage->rgb.blue[i]  * BluPercent);
  340.   
  341. -       grey[i] = (tmp / MaxIntensity) * MaxGrey;
  342. -     }
  343.       for (i=0; i<cimage->rgb.used; i++)
  344.         grey[i] = tone_scale_adjust(grey[i]);
  345.     }
  346. --- 86,96 ----
  347.     {
  348.       grey = (unsigned int *)lmalloc(sizeof(unsigned int) * cimage->rgb.used);
  349.       for (i=0; i<cimage->rgb.used; i++)
  350. !       grey[i]=
  351. !     (colorIntensity(cimage->rgb.red[i],
  352. !             cimage->rgb.green[i],
  353. !             cimage->rgb.blue[i]) >> 1);
  354.   
  355.       for (i=0; i<cimage->rgb.used; i++)
  356.         grey[i] = tone_scale_adjust(grey[i]);
  357.     }
  358. ***************
  359. *** 136,152 ****
  360.         src  += spl;
  361.         
  362.         if (grey == NULL)
  363. !       {
  364. !     tmp  = (cimage->rgb.red[color]   * RedPercent);
  365. !     tmp += (cimage->rgb.green[color] * GrnPercent);
  366. !     tmp += (cimage->rgb.blue[color]  * BluPercent);
  367. !     level = tone_scale_adjust((tmp / MaxIntensity) * MaxGrey);
  368. !       }
  369.         else
  370. -       {
  371.       level = grey[color];
  372. -       }
  373.   
  374.         curr[j] += level;
  375.       }
  376. --- 129,140 ----
  377.         src  += spl;
  378.         
  379.         if (grey == NULL)
  380. !     level =
  381. !       tone_scale_adjust(colorIntensity(cimage->rgb.red[color],
  382. !                        cimage->rgb.green[color],
  383. !                        cimage->rgb.blue[color]) >> 1);
  384.         else
  385.       level = grey[color];
  386.   
  387.         curr[j] += level;
  388.       }
  389. diff -c src.2.01/g3.c src.2.02/g3.c
  390. *** src.2.01/g3.c    Sun Sep 30 19:04:28 1990
  391. --- src.2.02/g3.c    Sat Dec  1 20:00:01 1990
  392. ***************
  393. *** 35,40 ****
  394. --- 35,41 ----
  395.   int g3_eof = 0;
  396.   int g3_eols;
  397.   int g3_rawzeros;
  398. + int g3_Xrawzeros;
  399.   int    maxlinelen;
  400.   int    rows, cols;
  401.   
  402. ***************
  403. *** 236,241 ****
  404. --- 237,243 ----
  405.           curbit = 0;
  406.           }
  407.       if (shdata & bmask[curbit]) {
  408. +         g3_Xrawzeros = g3_rawzeros;
  409.           g3_rawzeros = 0;
  410.           b = 1;
  411.           }
  412. ***************
  413. *** 280,286 ****
  414.       int    ret = 0;
  415.   
  416.       for (g3_rawzeros = 0; !g3_rawgetbit(fd) && !g3_eof;);
  417. !     if(g3_rawzeros >=11 && g3_rawzeros <= 15)
  418.           ret = 1;
  419.   
  420.       return(ret);
  421. --- 282,288 ----
  422.       int    ret = 0;
  423.   
  424.       for (g3_rawzeros = 0; !g3_rawgetbit(fd) && !g3_eof;);
  425. !     if(g3_Xrawzeros >=11 && g3_Xrawzeros <= 15)
  426.           ret = 1;
  427.   
  428.       return(ret);
  429. ***************
  430. *** 350,356 ****
  431.       }
  432.   
  433.       if(verbose)
  434. !         printf("  %s is a %dx%d G3 FAX image.\n", image->width, image->height);
  435.       return(image);
  436.   }
  437.   
  438. --- 352,358 ----
  439.       }
  440.   
  441.       if(verbose)
  442. !         printf("  %s is a %dx%d G3 FAX image.\n", name, image->width, image->height);
  443.       return(image);
  444.   }
  445.   
  446. diff -c src.2.01/halftone.c src.2.02/halftone.c
  447. *** src.2.01/halftone.c    Sun Sep 30 19:04:12 1990
  448. --- src.2.02/halftone.c    Wed Oct  3 12:01:07 1990
  449. ***************
  450. *** 13,23 ****
  451.   #include "copyright.h"
  452.   #include "image.h"
  453.   
  454.   /* 4x4 arrays used for dithering, arranged by nybble
  455.    */
  456.   
  457.   #define GRAYS    17 /* ((4 * 4) + 1) patterns for a good dither */
  458. ! #define GRAYSTEP ((unsigned long)(65536 * 3) / GRAYS)
  459.   
  460.   static byte DitherBits[GRAYS][4] = {
  461.     0xf, 0xf, 0xf, 0xf,
  462. --- 13,133 ----
  463.   #include "copyright.h"
  464.   #include "image.h"
  465.   
  466. + /* RGB intensity tables.  red is (val * 0.30), green is (val * 0.59), blue
  467. +  * is (val * .11), where val is intensity >> 8.  these are used by the
  468. +  * colorIntensity() macro in images.h.
  469. +  */
  470. + unsigned short RedIntensity[256]= {
  471. +       0,    76,   153,   230,   307,   384,   460,   537,
  472. +     614,   691,   768,   844,   921,   998,  1075,  1152,
  473. +    1228,  1305,  1382,  1459,  1536,  1612,  1689,  1766,
  474. +    1843,  1920,  1996,  2073,  2150,  2227,  2304,  2380,
  475. +    2457,  2534,  2611,  2688,  2764,  2841,  2918,  2995,
  476. +    3072,  3148,  3225,  3302,  3379,  3456,  3532,  3609,
  477. +    3686,  3763,  3840,  3916,  3993,  4070,  4147,  4224,
  478. +    4300,  4377,  4454,  4531,  4608,  4684,  4761,  4838,
  479. +    4915,  4992,  5068,  5145,  5222,  5299,  5376,  5452,
  480. +    5529,  5606,  5683,  5760,  5836,  5913,  5990,  6067,
  481. +    6144,  6220,  6297,  6374,  6451,  6528,  6604,  6681,
  482. +    6758,  6835,  6912,  6988,  7065,  7142,  7219,  7296,
  483. +    7372,  7449,  7526,  7603,  7680,  7756,  7833,  7910,
  484. +    7987,  8064,  8140,  8217,  8294,  8371,  8448,  8524,
  485. +    8601,  8678,  8755,  8832,  8908,  8985,  9062,  9139,
  486. +    9216,  9292,  9369,  9446,  9523,  9600,  9676,  9753,
  487. +    9830,  9907,  9984, 10060, 10137, 10214, 10291, 10368,
  488. +   10444, 10521, 10598, 10675, 10752, 10828, 10905, 10982,
  489. +   11059, 11136, 11212, 11289, 11366, 11443, 11520, 11596,
  490. +   11673, 11750, 11827, 11904, 11980, 12057, 12134, 12211,
  491. +   12288, 12364, 12441, 12518, 12595, 12672, 12748, 12825,
  492. +   12902, 12979, 13056, 13132, 13209, 13286, 13363, 13440,
  493. +   13516, 13593, 13670, 13747, 13824, 13900, 13977, 14054,
  494. +   14131, 14208, 14284, 14361, 14438, 14515, 14592, 14668,
  495. +   14745, 14822, 14899, 14976, 15052, 15129, 15206, 15283,
  496. +   15360, 15436, 15513, 15590, 15667, 15744, 15820, 15897,
  497. +   15974, 16051, 16128, 16204, 16281, 16358, 16435, 16512,
  498. +   16588, 16665, 16742, 16819, 16896, 16972, 17049, 17126,
  499. +   17203, 17280, 17356, 17433, 17510, 17587, 17664, 17740,
  500. +   17817, 17894, 17971, 18048, 18124, 18201, 18278, 18355,
  501. +   18432, 18508, 18585, 18662, 18739, 18816, 18892, 18969,
  502. +   19046, 19123, 19200, 19276, 19353, 19430, 19507, 19584
  503. + };
  504. + unsigned short GreenIntensity[256]= {
  505. +      0,  151,  302,  453,  604,  755,  906, 1057,
  506. +   1208, 1359, 1510, 1661, 1812, 1963, 2114, 2265,
  507. +   2416, 2567, 2718, 2869, 3020, 3171, 3322, 3473,
  508. +   3624, 3776, 3927, 4078, 4229, 4380, 4531, 4682,
  509. +   4833, 4984, 5135, 5286, 5437, 5588, 5739, 5890,
  510. +   6041, 6192, 6343, 6494, 6645, 6796, 6947, 7098,
  511. +   7249, 7400, 7552, 7703, 7854, 8005, 8156, 8307,
  512. +   8458, 8609, 8760, 8911, 9062, 9213, 9364, 9515,
  513. +   9666, 9817, 9968,10119,10270,10421,10572,10723,
  514. +  10874,11025,11176,11328,11479,11630,11781,11932,
  515. +  12083,12234,12385,12536,12687,12838,12989,13140,
  516. +  13291,13442,13593,13744,13895,14046,14197,14348,
  517. +  14499,14650,14801,14952,15104,15255,15406,15557,
  518. +  15708,15859,16010,16161,16312,16463,16614,16765,
  519. +  16916,17067,17218,17369,17520,17671,17822,17973,
  520. +  18124,18275,18426,18577,18728,18880,19031,19182,
  521. +  19333,19484,19635,19786,19937,20088,20239,20390,
  522. +  20541,20692,20843,20994,21145,21296,21447,21598,
  523. +  21749,21900,22051,22202,22353,22504,22656,22807,
  524. +  22958,23109,23260,23411,23562,23713,23864,24015,
  525. +  24166,24317,24468,24619,24770,24921,25072,25223,
  526. +  25374,25525,25676,25827,25978,26129,26280,26432,
  527. +  26583,26734,26885,27036,27187,27338,27489,27640,
  528. +  27791,27942,28093,28244,28395,28546,28697,28848,
  529. +  28999,29150,29301,29452,29603,29754,29905,30056,
  530. +  30208,30359,30510,30661,30812,30963,31114,31265,
  531. +  31416,31567,31718,31869,32020,32171,32322,32473,
  532. +  32624,32775,32926,33077,33228,33379,33530,33681,
  533. +  33832,33984,34135,34286,34437,34588,34739,34890,
  534. +  35041,35192,35343,35494,35645,35796,35947,36098,
  535. +  36249,36400,36551,36702,36853,37004,37155,37306,
  536. +  37457,37608,37760,37911,38062,38213,38364,38515
  537. + };
  538. + unsigned short BlueIntensity[256]= {
  539. +      0,   28,   56,   84,  112,  140,  168,  197,
  540. +    225,  253,  281,  309,  337,  366,  394,  422,
  541. +    450,  478,  506,  535,  563,  591,  619,  647,
  542. +    675,  704,  732,  760,  788,  816,  844,  872,
  543. +    901,  929,  957,  985, 1013, 1041, 1070, 1098,
  544. +   1126, 1154, 1182, 1210, 1239, 1267, 1295, 1323,
  545. +   1351, 1379, 1408, 1436, 1464, 1492, 1520, 1548,
  546. +   1576, 1605, 1633, 1661, 1689, 1717, 1745, 1774,
  547. +   1802, 1830, 1858, 1886, 1914, 1943, 1971, 1999,
  548. +   2027, 2055, 2083, 2112, 2140, 2168, 2196, 2224,
  549. +   2252, 2280, 2309, 2337, 2365, 2393, 2421, 2449,
  550. +   2478, 2506, 2534, 2562, 2590, 2618, 2647, 2675,
  551. +   2703, 2731, 2759, 2787, 2816, 2844, 2872, 2900,
  552. +   2928, 2956, 2984, 3013, 3041, 3069, 3097, 3125,
  553. +   3153, 3182, 3210, 3238, 3266, 3294, 3322, 3351,
  554. +   3379, 3407, 3435, 3463, 3491, 3520, 3548, 3576,
  555. +   3604, 3632, 3660, 3688, 3717, 3745, 3773, 3801,
  556. +   3829, 3857, 3886, 3914, 3942, 3970, 3998, 4026,
  557. +   4055, 4083, 4111, 4139, 4167, 4195, 4224, 4252,
  558. +   4280, 4308, 4336, 4364, 4392, 4421, 4449, 4477,
  559. +   4505, 4533, 4561, 4590, 4618, 4646, 4674, 4702,
  560. +   4730, 4759, 4787, 4815, 4843, 4871, 4899, 4928,
  561. +   4956, 4984, 5012, 5040, 5068, 5096, 5125, 5153,
  562. +   5181, 5209, 5237, 5265, 5294, 5322, 5350, 5378,
  563. +   5406, 5434, 5463, 5491, 5519, 5547, 5575, 5603,
  564. +   5632, 5660, 5688, 5716, 5744, 5772, 5800, 5829,
  565. +   5857, 5885, 5913, 5941, 5969, 5998, 6026, 6054,
  566. +   6082, 6110, 6138, 6167, 6195, 6223, 6251, 6279,
  567. +   6307, 6336, 6364, 6392, 6420, 6448, 6476, 6504,
  568. +   6533, 6561, 6589, 6617, 6645, 6673, 6702, 6730,
  569. +   6758, 6786, 6814, 6842, 6871, 6899, 6927, 6955,
  570. +   6983, 7011, 7040, 7068, 7096, 7124, 7152, 7180
  571. + };
  572.   /* 4x4 arrays used for dithering, arranged by nybble
  573.    */
  574.   
  575.   #define GRAYS    17 /* ((4 * 4) + 1) patterns for a good dither */
  576. ! #define GRAYSTEP ((unsigned long)(65536 / GRAYS))
  577.   
  578.   static byte DitherBits[GRAYS][4] = {
  579.     0xf, 0xf, 0xf, 0xf,
  580. ***************
  581. *** 85,93 ****
  582.       index= (unsigned int *)lmalloc(sizeof(unsigned int) * cimage->rgb.used);
  583.       for (x= 0; x < cimage->rgb.used; x++) {
  584.         *(index + x)=
  585. !     ((unsigned long)(*(cimage->rgb.red + x)) +
  586. !      *(cimage->rgb.green + x) +
  587. !      *(cimage->rgb.blue + x)) / GRAYSTEP;
  588.         if (*(index + x) >= GRAYS) /* rounding errors can do this */
  589.       *(index + x)= GRAYS - 1;
  590.       }
  591. --- 195,203 ----
  592.       index= (unsigned int *)lmalloc(sizeof(unsigned int) * cimage->rgb.used);
  593.       for (x= 0; x < cimage->rgb.used; x++) {
  594.         *(index + x)=
  595. !     ((unsigned long)colorIntensity(*(cimage->rgb.red + x),
  596. !                        *(cimage->rgb.green + x),
  597. !                        *(cimage->rgb.blue + x))) / GRAYSTEP;
  598.         if (*(index + x) >= GRAYS) /* rounding errors can do this */
  599.       *(index + x)= GRAYS - 1;
  600.       }
  601. ***************
  602. *** 107,115 ****
  603.         if (index)
  604.       dindex= *(index + color);
  605.         else {
  606. !     dindex= ((unsigned long)(*(cimage->rgb.red + color)) +
  607. !          *(cimage->rgb.green + color) +
  608. !          *(cimage->rgb.blue + color)) / GRAYSTEP;
  609.       if (dindex >= GRAYS) /* rounding errors can do this */
  610.         dindex= GRAYS - 1;
  611.         }
  612. --- 217,226 ----
  613.         if (index)
  614.       dindex= *(index + color);
  615.         else {
  616. !     dindex= 
  617. !       ((unsigned long)colorIntensity(*(cimage->rgb.red + x),
  618. !                      *(cimage->rgb.green + x),
  619. !                      *(cimage->rgb.blue + x))) / GRAYSTEP;
  620.       if (dindex >= GRAYS) /* rounding errors can do this */
  621.         dindex= GRAYS - 1;
  622.         }
  623. diff -c src.2.01/image.h src.2.02/image.h
  624. *** src.2.01/image.h    Sun Sep 30 19:04:29 1990
  625. --- src.2.02/image.h    Sun Dec  2 12:21:16 1990
  626. ***************
  627. *** 35,43 ****
  628.   #define ZSTDIN    2 /* file is stdin */
  629.   
  630.   typedef struct rgbmap {
  631. !   unsigned int  size;  /* size of RGB map */
  632. !   unsigned int  used;  /* number of colors used in RGB map */
  633. !   Intensity    *red;   /* color values in X style */
  634.     Intensity    *green;
  635.     Intensity    *blue;
  636.   } RGBMap;
  637. --- 35,44 ----
  638.   #define ZSTDIN    2 /* file is stdin */
  639.   
  640.   typedef struct rgbmap {
  641. !   unsigned int  size;       /* size of RGB map */
  642. !   unsigned int  used;       /* number of colors used in RGB map */
  643. !   unsigned int  compressed; /* image uses colormap fully */
  644. !   Intensity    *red;        /* color values in X style */
  645.     Intensity    *green;
  646.     Intensity    *blue;
  647.   } RGBMap;
  648. ***************
  649. *** 62,67 ****
  650. --- 63,82 ----
  651.   #define BITMAPP(IMAGE) ((IMAGE)->type == IBITMAP)
  652.   #define RGBP(IMAGE)    ((IMAGE)->type == IRGB)
  653.   
  654. + /* special case 1-byte transfers so they're inline
  655. +  */
  656. + #define memToVal(PTR,LEN)    ((LEN) == 1 ? (unsigned long)(*(PTR)) : \
  657. +                   doMemToVal(PTR,LEN))
  658. + #define memToValLSB(PTR,LEN) ((LEN) == 1 ? (unsigned long)(*(PTR)) : \
  659. +                   doMemToValLSB(PTR,LEN))
  660. + #define valToMem(VAL,PTR,LEN)    ((LEN) == 1 ? \
  661. +                   (unsigned long)(*(PTR) = (byte)(VAL)) : \
  662. +                   doValToMem(VAL,PTR,LEN))
  663. + #define valToMemLSB(VAL,PTR,LEN) ((LEN) == 1 ? \
  664. +                   (unsigned long)(*(PTR) = (byte)(VAL)) : \
  665. +                   (int)doValToMemLSB(VAL,PTR,LEN))
  666.   /* function declarations
  667.    */
  668.   
  669. ***************
  670. *** 68,73 ****
  671. --- 83,91 ----
  672.   Image *clip(); /* clip.c */
  673.   
  674.   void brighten(); /* bright.c */
  675. + void equalize();
  676. + void gray();
  677. + void normalize();
  678.   
  679.   void compress(); /* compress.c */
  680.   
  681. ***************
  682. *** 105,115 ****
  683.   void reduceRGBMap(); /* reduce.c */
  684.   void reduce();
  685.   
  686. ! unsigned long memToVal(); /* value.c */
  687. ! void          valToMem();
  688. ! unsigned long memToValLSB();
  689. ! void          valToMemLSB();
  690.   
  691.   Image *zoom(); /* zoom.c */
  692.   Image *rotate(); /* rotate.c */
  693.   Image *smooth(); /* smooth.c */
  694. --- 123,148 ----
  695.   void reduceRGBMap(); /* reduce.c */
  696.   void reduce();
  697.   
  698. ! /* doMemToVal and doMemToValLSB used to be void type but some compilers
  699. !  * (particularly the 4.1.1 SunOS compiler) couldn't handle the
  700. !  * (void)(thing= value) conversion used in the macros.
  701. !  */
  702.   
  703. + unsigned long doMemToVal(); /* value.c */
  704. + unsigned long doValToMem();
  705. + unsigned long doMemToValLSB();
  706. + unsigned long doValToMemLSB();
  707.   Image *zoom(); /* zoom.c */
  708.   Image *rotate(); /* rotate.c */
  709.   Image *smooth(); /* smooth.c */
  710. + /* this returns the (approximate) intensity of an RGB triple
  711. +  */
  712. + #define colorIntensity(R,G,B) \
  713. +   (RedIntensity[(R) >> 8] + GreenIntensity[(G) >> 8] + BlueIntensity[(B) >> 8])
  714. + extern unsigned short RedIntensity[];
  715. + extern unsigned short GreenIntensity[];
  716. + extern unsigned short BlueIntensity[];
  717. diff -c src.2.01/imagetypes.h src.2.02/imagetypes.h
  718. *** src.2.01/imagetypes.h    Sun Sep 30 19:04:29 1990
  719. --- src.2.02/imagetypes.h    Sat Dec  1 20:02:53 1990
  720. ***************
  721. *** 52,60 ****
  722.     rleIdent,       rleLoad,       "Utah RLE Image",
  723.     xwdIdent,       xwdLoad,       "X Window Dump",
  724.     mcidasIdent,    mcidasLoad,    "McIDAS areafile",
  725.     macIdent,       macLoad,       "MacPaint Image",
  726.     xpixmapIdent,   xpixmapLoad,   "X Pixmap",
  727.     xbitmapIdent,   xbitmapLoad,   "X Bitmap",
  728. -   g3Ident,        g3Load,        "G3 FAX Image",
  729.     NULL,           NULL,          NULL
  730.   };
  731. --- 52,60 ----
  732.     rleIdent,       rleLoad,       "Utah RLE Image",
  733.     xwdIdent,       xwdLoad,       "X Window Dump",
  734.     mcidasIdent,    mcidasLoad,    "McIDAS areafile",
  735. +   g3Ident,        g3Load,        "G3 FAX Image",
  736.     macIdent,       macLoad,       "MacPaint Image",
  737.     xpixmapIdent,   xpixmapLoad,   "X Pixmap",
  738.     xbitmapIdent,   xbitmapLoad,   "X Bitmap",
  739.     NULL,           NULL,          NULL
  740.   };
  741. diff -c src.2.01/kljcpyrght.h src.2.02/kljcpyrght.h
  742. *** src.2.01/kljcpyrght.h    Sun Sep 30 19:04:13 1990
  743. --- src.2.02/kljcpyrght.h    Sat Dec  1 14:26:38 1990
  744. ***************
  745. *** 21,26 ****
  746. --- 21,28 ----
  747.     CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  748.   ****/
  749.   
  750. + #ifndef __SABER__
  751.   static char *KLJCopyright = "Copyright 1989, 1990 Kirk L. Johnson";
  752. + #endif
  753.   #define _KLJ_COPYRIGHT_
  754.   #endif
  755. diff -c src.2.01/mac.c src.2.02/mac.c
  756. *** src.2.01/mac.c    Sun Sep 30 19:04:13 1990
  757. --- src.2.02/mac.c    Sat Dec  1 20:05:17 1990
  758. ***************
  759. *** 73,85 ****
  760.     if (zread(ins, hp, ADD_HDR_LEN) != ADD_HDR_LEN)
  761.       return MACIN_ERR_EOF;
  762.   
  763. !   /*
  764. !    * if mhsum = 0 this is probably a
  765. !    * a g3 fax file.
  766. !    */
  767. !   for (i = 0; i < 10; i++) mhsum += mhdr[1];
  768. !   if (mhdr[0] != MAC_MAGIC && mhsum != 0)
  769.       return MACIN_ERR_BAD_SD;
  770.   
  771.     /* Get image name  (if available) */
  772. --- 73,79 ----
  773.     if (zread(ins, hp, ADD_HDR_LEN) != ADD_HDR_LEN)
  774.       return MACIN_ERR_EOF;
  775.   
  776. !   if (mhdr[0] != MAC_MAGIC)
  777.       return MACIN_ERR_BAD_SD;
  778.   
  779.     /* Get image name  (if available) */
  780. diff -c src.2.01/mc_tables.c src.2.02/mc_tables.c
  781. *** src.2.01/mc_tables.c    Sun Sep 30 19:04:34 1990
  782. --- src.2.02/mc_tables.c    Sun Dec  2 14:17:20 1990
  783. ***************
  784. *** 1,5 ****
  785. - /* $Id: mc_tables.c,v 1.1 89/10/16 16:27:48 davis Exp $ */
  786.   /*
  787.    *  From McIDAS Reference Manual
  788.    *     Introduction - pg 21
  789. --- 1,3 ----
  790. diff -c src.2.01/mcidas.h src.2.02/mcidas.h
  791. *** src.2.01/mcidas.h    Sun Sep 30 19:04:35 1990
  792. --- src.2.02/mcidas.h    Sun Dec  2 14:17:54 1990
  793. ***************
  794. *** 1,4 ****
  795. ! /*    $Id: mcidas.h,v 1.1 90/09/28 20:26:36 davis Exp $ */
  796.   
  797.   /* Argh, looks like the numbers are in vax byte order */
  798.   
  799. --- 1,5 ----
  800. ! /* mcidas.h
  801. !  */
  802.   
  803.   /* Argh, looks like the numbers are in vax byte order */
  804.   
  805. ***************
  806. *** 69,73 ****
  807.       struct area_dir *dir ;
  808.       struct navigation *nav ;
  809.       unsigned char *image ;
  810. !     unsigned char *private ; /* conveninence pointer */
  811.   } ;
  812. --- 70,74 ----
  813.       struct area_dir *dir ;
  814.       struct navigation *nav ;
  815.       unsigned char *image ;
  816. !     unsigned char *priv ; /* conveninence pointer */
  817.   } ;
  818. diff -c src.2.01/misc.c src.2.02/misc.c
  819. *** src.2.01/misc.c    Sun Sep 30 19:04:13 1990
  820. --- src.2.02/misc.c    Sun Dec  2 14:05:55 1990
  821. ***************
  822. *** 19,24 ****
  823. --- 19,25 ----
  824.     printf("Global options:\n");
  825.     printf("  -onroot               - load image onto root window\n");
  826.     printf("  -border colorname     - border image with this color\n");
  827. +   printf("  -default              - set root window to default pattern\n");
  828.     printf("  -display dispname     - destination display\n");
  829.     printf("  -fullscreen           - use entire screen for display\n");
  830.     printf("  -geometry WxH+X+Y     - destination size and location\n");
  831. ***************
  832. *** 27,32 ****
  833. --- 28,34 ----
  834.     printf("  -list                 - list images in path\n");
  835.     printf("  -install              - explicitly install colormap\n");
  836.     printf("  -path                 - show image path for loading\n");
  837. +   printf("  -private              - force allocation of private colormap\n");
  838.     printf("  -quiet                - silence is golden\n");
  839.     printf("  -slideshow            - show images in slideshow style\n");
  840.     printf("  -supported            - show supported image types\n");
  841. ***************
  842. *** 36,51 ****
  843.     printf("Image_options:\n");
  844.     printf("  -at X,Y               - load image at location\n");
  845.     printf("  -background colorname - background color for bitmap images\n");
  846. -   printf("  -gamma display_gamma  - specify display gamma - default = 1.0\n");
  847.     printf("                        - typical display needs 2.0 - 2.5\n");
  848.     printf("  -brighten percentage  - specify brightness multiplier\n");
  849.     printf("  -center               - center image\n");
  850. -   printf("  -colors number        - specify maximum number of RGB colors\n");
  851.     printf("  -clip X,Y,W,H         - use clipped portion of image\n");
  852.     printf("  -dither               - dither color image to bitmap image\n");
  853.     printf("  -foreground colorname - foreground color for bitmap images\n");
  854.     printf("  -halftone             - halftone a color image to bitmap image\n");
  855.     printf("  -name name            - force next argument to be image name\n");
  856.     printf("  -rotate degrees       - rotate an image by a 90 degree angle\n");
  857.     printf("  -smooth               - smooth a color image\n");
  858.     printf("  -xzoom percentage     - zoom the X axis by a percentage\n");
  859. --- 38,55 ----
  860.     printf("Image_options:\n");
  861.     printf("  -at X,Y               - load image at location\n");
  862.     printf("  -background colorname - background color for bitmap images\n");
  863.     printf("                        - typical display needs 2.0 - 2.5\n");
  864.     printf("  -brighten percentage  - specify brightness multiplier\n");
  865.     printf("  -center               - center image\n");
  866.     printf("  -clip X,Y,W,H         - use clipped portion of image\n");
  867. +   printf("  -colors number        - specify maximum number of RGB colors\n");
  868.     printf("  -dither               - dither color image to bitmap image\n");
  869.     printf("  -foreground colorname - foreground color for bitmap images\n");
  870. +   printf("  -gamma display_gamma  - specify display gamma - default = 1.0\n");
  871. +   printf("  -gray                 - convert to grayscale (also -grey)\n");
  872.     printf("  -halftone             - halftone a color image to bitmap image\n");
  873.     printf("  -name name            - force next argument to be image name\n");
  874. +   printf("  -normalize            - convert image to normalized b & w\n");
  875.     printf("  -rotate degrees       - rotate an image by a 90 degree angle\n");
  876.     printf("  -smooth               - smooth a color image\n");
  877.     printf("  -xzoom percentage     - zoom the X axis by a percentage\n");
  878. ***************
  879. *** 122,127 ****
  880. --- 126,137 ----
  881.       freeImage(image);
  882.       image= tmpimage;
  883.     }
  884. +   if (options->gray) /* convert image to grayscale */
  885. +     gray(image, verbose);
  886. +   if (options->normalize) /* normalize image */
  887. +     normalize(image, verbose);
  888.   
  889.     if (options->bright) /* alter image brightness */
  890.       brighten(image, options->bright, verbose);
  891. diff -c src.2.01/mit.cpyrght src.2.02/mit.cpyrght
  892. *** src.2.01/mit.cpyrght    Sun Sep 30 19:04:13 1990
  893. --- src.2.02/mit.cpyrght    Sat Dec  1 14:26:50 1990
  894. ***************
  895. *** 20,26 ****
  896. --- 20,28 ----
  897.    * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  898.    */
  899.   
  900. + #ifndef __SABER__
  901.   static char *MitCopyright=
  902.     "Copyright 1989 Massachusetts Institute of Technology";
  903. + #endif
  904.   #define _MIT_COPYRIGHT_
  905.   #endif
  906. diff -c src.2.01/mrmcpyrght.h src.2.02/mrmcpyrght.h
  907. *** src.2.01/mrmcpyrght.h    Sun Sep 30 19:04:13 1990
  908. --- src.2.02/mrmcpyrght.h    Sat Dec  1 14:27:52 1990
  909. ***************
  910. *** 21,26 ****
  911. --- 21,28 ----
  912.     CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  913.   ****/
  914.   
  915. + #ifndef __SABER__
  916.   static char *MRMCopyright = "Copyright 1990 Mark Majhor";
  917. + #endif
  918.   #define _MRM_COPYRIGHT_
  919.   #endif
  920. diff -c src.2.01/new.c src.2.02/new.c
  921. *** src.2.01/new.c    Sun Sep 30 19:04:13 1990
  922. --- src.2.02/new.c    Sun Dec  2 12:29:54 1990
  923. ***************
  924. *** 28,33 ****
  925. --- 28,34 ----
  926.   {
  927.     rgb->used= 0;
  928.     rgb->size= size;
  929. +   rgb->compressed= 0;
  930.     rgb->red= (Intensity *)lmalloc(sizeof(Intensity) * size);
  931.     rgb->green= (Intensity *)lmalloc(sizeof(Intensity) * size);
  932.     rgb->blue= (Intensity *)lmalloc(sizeof(Intensity) * size);
  933. diff -c src.2.01/patchlevel src.2.02/patchlevel
  934. *** src.2.01/patchlevel    Sun Sep 30 19:04:30 1990
  935. --- src.2.02/patchlevel    Wed Oct  3 11:01:10 1990
  936. ***************
  937. *** 2,5 ****
  938.    */
  939.   
  940.   #define VERSION    "2"
  941. ! #define PATCHLEVEL "01"
  942. --- 2,5 ----
  943.    */
  944.   
  945.   #define VERSION    "2"
  946. ! #define PATCHLEVEL "02"
  947. diff -c src.2.01/reduce.c src.2.02/reduce.c
  948. *** src.2.01/reduce.c    Sun Sep 30 19:04:14 1990
  949. --- src.2.02/reduce.c    Sun Dec  2 12:29:25 1990
  950. ***************
  951. *** 175,180 ****
  952. --- 175,182 ----
  953.     lfree((byte *)dists);
  954.     lfree((byte *)same);
  955.   
  956. +   rgb->compressed= 0;
  957.     if (verbose)
  958.       printf("done\n");
  959.   }
  960. diff -c src.2.01/rle.c src.2.02/rle.c
  961. *** src.2.01/rle.c    Sun Sep 30 19:04:14 1990
  962. --- src.2.02/rle.c    Sat Dec  1 20:10:23 1990
  963. ***************
  964. *** 37,43 ****
  965.   static int y_min;        /* copy of picture y_min */
  966.   
  967.   /* option stuff (Not functional) */
  968. ! static float disp_gam = 2.0;    /* default display gamma correction factor */
  969.   static int gflag = 0;            /* if user supplies display gamma */
  970.   static int iflag=0;            /* user suplied image gamma */
  971.   static int lflag=0;            /* user supplied levels */
  972. --- 37,43 ----
  973.   static int y_min;        /* copy of picture y_min */
  974.   
  975.   /* option stuff (Not functional) */
  976. ! static float disp_gam = 1.0;    /* default display gamma correction factor */
  977.   static int gflag = 0;            /* if user supplies display gamma */
  978.   static int iflag=0;            /* user suplied image gamma */
  979.   static int lflag=0;            /* user supplied levels */
  980. diff -c src.2.01/rle.h src.2.02/rle.h
  981. *** src.2.01/rle.h    Sun Sep 30 19:04:14 1990
  982. --- src.2.02/rle.h    Sun Dec  2 14:14:10 1990
  983. ***************
  984. *** 27,57 ****
  985.    * 
  986.    * Added optimised dither square size globals
  987.    * 88/07/13 Graeme W. Gill
  988. -  *
  989. -  * $Header: svfb_global.h,v 2.7 86/11/10 11:25:18 thomas Exp $
  990. -  * $Log:    svfb_global.h,v $
  991. -  * Revision 2.7  86/11/10  11:25:18  thomas
  992. -  * Add rle_get_setup return codes.
  993. -  * Add is_seek flag to make pipe input work.
  994. -  * 
  995. -  * Revision 2.6  86/10/08  13:06:07  thomas
  996. -  * Add sv_comments field.
  997. -  * Add is_eof flag to Runget private data.
  998. -  * 
  999. -  * Revision 2.4  86/02/27  10:05:40  thomas
  1000. -  * Change for new sv_globals & sv_putrow interface.
  1001. -  * Add comments to data structure.
  1002. -  * 
  1003. -  * Revision 2.3  85/04/26  15:10:04  thomas
  1004. -  * New sv_globals structure.  sv_dispatch no longer global variable
  1005. -  * (incorporated into globals struct).
  1006. -  * 
  1007. -  * Revision 2.2  85/04/04  16:42:09  thomas
  1008. -  * Take out verbose flag, mapflag.  Add ncmap/cmaplen and map pointer.
  1009. -  * 
  1010. -  * Revision 2.1  85/03/05  16:02:03  thomas
  1011. -  * *** empty log message ***
  1012. -  * 
  1013.    */
  1014.   
  1015.   enum sv_dispatch {
  1016. --- 27,32 ----
  1017. ***************
  1018. *** 65,83 ****
  1019.    * pdp-11's (not sure if it's pdp11 or PDP11 ??)
  1020.    * are considered BIGENDIAN machines.
  1021.    */
  1022. - #if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
  1023. - #if !defined(vax) && !defined(pdp11) && !defined(ns32000) && !defined(i386)
  1024. - #define BIG_ENDIAN
  1025. - #else
  1026. - #define LITTLE_ENDIAN
  1027. - #endif
  1028. - #endif
  1029.   
  1030. ! #ifdef BIG_ENDIAN
  1031. ! #define SWAB(shrt)  (shrt = ((shrt >> 8) & 0xff) | ((shrt << 8) & 0xff00))
  1032. ! #else
  1033. ! #define    SWAB(shrt)
  1034. ! #endif
  1035.   
  1036.   /* fix up some bezerklysims */
  1037.   #ifndef bzero
  1038. --- 40,47 ----
  1039.    * pdp-11's (not sure if it's pdp11 or PDP11 ??)
  1040.    * are considered BIGENDIAN machines.
  1041.    */
  1042.   
  1043. ! #define SWAB(val) (val= memToValLSB(&val, sizeof(val)))
  1044.   
  1045.   /* fix up some bezerklysims */
  1046.   #ifndef bzero
  1047. diff -c src.2.01/rlelib.c src.2.02/rlelib.c
  1048. *** src.2.01/rlelib.c    Sun Sep 30 19:04:32 1990
  1049. --- src.2.02/rlelib.c    Sun Dec  2 14:16:38 1990
  1050. ***************
  1051. *** 46,53 ****
  1052.    *         University of Utah
  1053.    * Date:    Mon Aug  9 1982
  1054.    * Copyright (c) 1982 Spencer W. Thomas
  1055. -  * 
  1056. -  * $Header: XtndRunsv.h,v 2.2 85/04/26 15:05:30 thomas Exp $
  1057.    */
  1058.   
  1059.   #ifndef XTNDRUNSV
  1060. --- 46,51 ----
  1061. ***************
  1062. *** 118,125 ****
  1063.    *         University of Utah
  1064.    * Date:    Mon Aug  9 1982
  1065.    * Copyright (c) 1982 Spencer W. Thomas
  1066. -  * 
  1067. -  * $Header: svfb.h,v 2.4 86/02/27 10:03:26 thomas Exp $
  1068.    */
  1069.   
  1070.   /* ****************************************************************
  1071. --- 116,121 ----
  1072. ***************
  1073. *** 197,215 ****
  1074.    *         University of Utah
  1075.    * Date:    Thu Apr 25 1985
  1076.    * Copyright (c) 1985,1986 Spencer W. Thomas
  1077. -  * 
  1078. -  * $Header: svfb_global.c,v 2.6 86/02/27 10:05:23 thomas Exp $
  1079. -  * $Log:    svfb_global.c,v $
  1080. -  * Revision 2.6  86/02/27  10:05:23  thomas
  1081. -  * Change for new sv_globals
  1082. -  * 
  1083. -  * Revision 2.5  86/02/25  17:32:18  thomas
  1084. -  * Take out misc.h
  1085. -  * 
  1086. -  * Revision 2.4  85/04/26  15:09:27  thomas
  1087. -  * Add header comment.  Change DTable to sv_DTable.  Changes for new
  1088. -  * sv_globals structure.
  1089. -  * 
  1090.    */
  1091.   
  1092.   
  1093. --- 193,198 ----
  1094. ***************
  1095. *** 296,307 ****
  1096.    *         University of Utah
  1097.    * Date:    Mon Aug  9 1982
  1098.    * Copyright (c) 1982,1986 Spencer W. Thomas
  1099. -  * 
  1100. -  * $Header: Runsv.c,v 2.9 86/02/27 10:01:13 thomas Locked $
  1101. -  * 
  1102. -  * Modified by:    Todd W. Fuqua
  1103. -  *     Date:    Jul 22 1984
  1104. -  * convert to new RLE format to make room for larger frame buffers
  1105.    */
  1106.   
  1107.   /* THIS IS WAY OUT OF DATE.  See rle.5.
  1108. --- 279,284 ----
  1109. ***************
  1110. *** 813,852 ****
  1111.    *         University of Utah
  1112.    * Date:    Wed Apr 10 1985
  1113.    * Copyright (c) 1985 Spencer W. Thomas
  1114. -  * 
  1115. -  * $Header: rle_getrow.c,v 1.12 86/11/10 12:30:34 thomas Exp $
  1116. -  * $Log:    rle_getrow.c,v $
  1117. -  * Revision 1.12  86/11/10  12:30:34  thomas
  1118. -  * NULL comments field if no comment in input file.
  1119. -  * 
  1120. -  * Revision 1.11  86/11/10  11:27:01  thomas
  1121. -  * Remove infile arguments.
  1122. -  * 
  1123. -  * Revision 1.10  86/11/10  11:19:04  thomas
  1124. -  * Fix to work with pipe input.
  1125. -  * 
  1126. -  * Revision 1.9  86/10/08  13:06:32  thomas
  1127. -  * Add header comments.
  1128. -  * Add EOF opcode.
  1129. -  * 
  1130. -  * Revision 1.6  86/02/27  10:05:55  thomas
  1131. -  * Change for new sv_globals interface.  Put "static" vars in structure.
  1132. -  * 
  1133. -  * Revision 1.5  86/02/25  17:32:28  thomas
  1134. -  * Add debugging.
  1135. -  * 
  1136. -  * Revision 1.4  86/02/11  11:38:09  thomas
  1137. -  * Oops: Only did clear to background right for ncolors = 3.
  1138. -  * Some lint fixes.
  1139. -  * 
  1140. -  * Revision 1.3  86/02/11  11:27:52  thomas
  1141. -  * Handle alpha channel.  Use bfill routine for efficiency.
  1142. -  * 
  1143. -  * Revision 1.2  85/05/22  15:09:23  thomas
  1144. -  * Swap magic number on BIGENDIAN machines.
  1145. -  * 
  1146. -  * Revision 1.1  85/05/22  12:36:21  thomas
  1147. -  * Initial revision
  1148.    * 
  1149.    */
  1150.   /*
  1151. --- 790,795 ----
  1152. diff -c src.2.01/root.c src.2.02/root.c
  1153. *** src.2.01/root.c    Sun Sep 30 19:04:14 1990
  1154. --- src.2.02/root.c    Sat Dec  1 16:21:13 1990
  1155. ***************
  1156. *** 14,20 ****
  1157.   #include "xloadimage.h"
  1158.   #include <X11/Xatom.h>
  1159.   
  1160. ! #define RETAIN_PROP_NAME    "XA_XLOADIMAGE_COLORS_XID"
  1161.   
  1162.   static void
  1163.   updateProperty(dpy, w, name, type, format, data, nelem)
  1164. --- 14,20 ----
  1165.   #include "xloadimage.h"
  1166.   #include <X11/Xatom.h>
  1167.   
  1168. ! #define RETAIN_PROP_NAME    "_XSETROOT_ID"
  1169.   
  1170.   static void
  1171.   updateProperty(dpy, w, name, type, format, data, nelem)
  1172. ***************
  1173. *** 134,140 ****
  1174.     freePrevious(disp, RootWindow(disp, scrn));
  1175.   
  1176.     if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn), image,
  1177. !              &pixmap, &xcmap, verbose))
  1178.       exit(1);
  1179.   
  1180.     /* changing the root colormap is A Bad Thing, so deny it.
  1181. --- 134,140 ----
  1182.     freePrevious(disp, RootWindow(disp, scrn));
  1183.   
  1184.     if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn), image,
  1185. !              &pixmap, &xcmap, 0, verbose))
  1186.       exit(1);
  1187.   
  1188.     /* changing the root colormap is A Bad Thing, so deny it.
  1189. diff -c src.2.01/send.c src.2.02/send.c
  1190. *** src.2.01/send.c    Sun Sep 30 19:04:14 1990
  1191. --- src.2.02/send.c    Sat Dec  1 20:27:02 1990
  1192. ***************
  1193. *** 11,17 ****
  1194.   #include "copyright.h"
  1195.   #include "xloadimage.h"
  1196.   
  1197. ! unsigned int sendImageToX(disp, scrn, visual, image, pixmap, cmap, verbose)
  1198.        Display      *disp;
  1199.        int           scrn;
  1200.        Visual       *visual;
  1201. --- 11,19 ----
  1202.   #include "copyright.h"
  1203.   #include "xloadimage.h"
  1204.   
  1205. ! unsigned int sendImageToX(disp, scrn, visual, image, pixmap, cmap,
  1206. !               private_cmap,
  1207. !               verbose)
  1208.        Display      *disp;
  1209.        int           scrn;
  1210.        Visual       *visual;
  1211. ***************
  1212. *** 18,23 ****
  1213. --- 20,26 ----
  1214.        Image        *image;
  1215.        Pixmap       *pixmap;
  1216.        Colormap     *cmap;
  1217. +      unsigned int  private_cmap;
  1218.        unsigned int  verbose;
  1219.   { Pixel        *index;
  1220.     unsigned int  a, b, newmap, x, y, linelen, ddepth, dpixlen;
  1221. ***************
  1222. *** 45,54 ****
  1223.     index= (Pixel *)lmalloc(sizeof(Pixel) * image->rgb.used);
  1224.     xcolor.flags= DoRed | DoGreen | DoBlue;
  1225.   
  1226. !   /* get the colormap to use
  1227.      */
  1228.   
  1229. !   if (visual == DefaultVisual(disp, scrn)) {
  1230.       *cmap= DefaultColormap(disp, scrn);
  1231.       newmap= 0;
  1232.   
  1233. --- 48,64 ----
  1234.     index= (Pixel *)lmalloc(sizeof(Pixel) * image->rgb.used);
  1235.     xcolor.flags= DoRed | DoGreen | DoBlue;
  1236.   
  1237. !   /* get the colormap to use.
  1238.      */
  1239.   
  1240. !   if (private_cmap) /* user asked us to use a private cmap */
  1241. !     newmap= 1;
  1242. !   /* if we're using the default visual, also use the default colormap
  1243. !    * so we share colors if possible.
  1244. !    */
  1245. !   else if (visual == DefaultVisual(disp, scrn)) {
  1246.       *cmap= DefaultColormap(disp, scrn);
  1247.       newmap= 0;
  1248.   
  1249. ***************
  1250. *** 70,79 ****
  1251.          * we had allocated and create a private colormap
  1252.          */
  1253.   
  1254. !       for (b= 0; b < a; b++)
  1255. !         XFreeColors(disp, *cmap, index + b, 1, 0);
  1256. !       *cmap= XCreateColormap(disp, RootWindow(disp, scrn), visual,
  1257. !                  AllocNone);
  1258.         newmap= 1;
  1259.         break;
  1260.       }
  1261. --- 80,86 ----
  1262.          * we had allocated and create a private colormap
  1263.          */
  1264.   
  1265. !       XFreeColors(disp, *cmap, index, a, 0);
  1266.         newmap= 1;
  1267.         break;
  1268.       }
  1269. ***************
  1270. *** 80,95 ****
  1271.         *(index + a)= xcolor.pixel;
  1272.       }
  1273.     }
  1274. !   else {
  1275.       if ((visual->class == PseudoColor) || (visual->class == GrayScale)) {
  1276.         *cmap= XCreateColormap(disp, RootWindow(disp, scrn), visual, AllocNone);
  1277.       }
  1278.       else
  1279.         *cmap= XCreateColormap(disp, RootWindow(disp, scrn), visual, AllocAll);
  1280. -     newmap= 1;
  1281. -   }
  1282. -   if (newmap) {
  1283.       for (a= 0; a < image->rgb.used; a++) /* count entries we got */
  1284.         if (! XAllocColorCells(disp, *cmap, False, NULL, 0, index + a, 1))
  1285.       break;
  1286. --- 87,103 ----
  1287.         *(index + a)= xcolor.pixel;
  1288.       }
  1289.     }
  1290. !   else
  1291. !     newmap= 1;
  1292. !   if (newmap) {
  1293. !     if (verbose)
  1294. !       printf("  Using private colormap\n");
  1295.       if ((visual->class == PseudoColor) || (visual->class == GrayScale)) {
  1296.         *cmap= XCreateColormap(disp, RootWindow(disp, scrn), visual, AllocNone);
  1297.       }
  1298.       else
  1299.         *cmap= XCreateColormap(disp, RootWindow(disp, scrn), visual, AllocAll);
  1300.       for (a= 0; a < image->rgb.used; a++) /* count entries we got */
  1301.         if (! XAllocColorCells(disp, *cmap, False, NULL, 0, index + a, 1))
  1302.       break;
  1303. ***************
  1304. *** 140,149 ****
  1305.       }
  1306.       pixptr= image->data;
  1307.       modimageptr = image->data;
  1308. !     dpixlen = ddepth / 8;
  1309. !     if(image->pixlen != dpixlen) {  /* Need to convert depth */
  1310. !     modimageptr = (byte *)lmalloc(image->height * image->width * dpixlen);
  1311. !     }
  1312.       destptr = modimageptr;
  1313.       
  1314.       for (y= 0; y < image->height; y++)
  1315. --- 148,157 ----
  1316.       }
  1317.       pixptr= image->data;
  1318.       modimageptr = image->data;
  1319. !     dpixlen= (ddepth + 7) / 8;
  1320. !     if (image->pixlen != dpixlen) /* Need to convert depth */
  1321. !     modimageptr=
  1322. !       (byte *)lmalloc(image->height * image->width * dpixlen);
  1323.       destptr = modimageptr;
  1324.       
  1325.       for (y= 0; y < image->height; y++)
  1326. ***************
  1327. *** 180,186 ****
  1328.         ximage->byte_order= MSBFirst;
  1329.   
  1330.         for (plane= 1 << (ddepth - 1); plane; plane >>= 1) {
  1331. !     pixptr= image->data;
  1332.       destline= bitplane;
  1333.       for (y= 0; y < image->height; y++) {
  1334.         destmask= 0x80;
  1335. --- 188,194 ----
  1336.         ximage->byte_order= MSBFirst;
  1337.   
  1338.         for (plane= 1 << (ddepth - 1); plane; plane >>= 1) {
  1339. !     pixptr= modimageptr;
  1340.       destline= bitplane;
  1341.       for (y= 0; y < image->height; y++) {
  1342.         destmask= 0x80;
  1343. diff -c src.2.01/smooth.c src.2.02/smooth.c
  1344. *** src.2.01/smooth.c    Sun Sep 30 19:04:32 1990
  1345. --- src.2.02/smooth.c    Sun Dec  2 11:58:29 1990
  1346. ***************
  1347. *** 44,50 ****
  1348.       carray[a].pixel= a;
  1349.       carray[a].sum= rgb->red[a] + rgb->green[a] + rgb->blue[a];
  1350.     }
  1351. !   qsort(carray, rgb->used, sizeof(struct colorarray), colorPredicate);
  1352.     return(carray);
  1353.   }
  1354.   
  1355. --- 44,51 ----
  1356.       carray[a].pixel= a;
  1357.       carray[a].sum= rgb->red[a] + rgb->green[a] + rgb->blue[a];
  1358.     }
  1359. !   qsort((char *)carray, rgb->used, sizeof(struct colorarray),
  1360. !     colorPredicate);
  1361.     return(carray);
  1362.   }
  1363.   
  1364. diff -c src.2.01/value.c src.2.02/value.c
  1365. *** src.2.01/value.c    Sun Sep 30 19:04:15 1990
  1366. --- src.2.02/value.c    Sat Dec  1 13:57:20 1990
  1367. ***************
  1368. *** 13,19 ****
  1369.   #include "copyright.h"
  1370.   #include "image.h"
  1371.   
  1372. ! unsigned long memToVal(p, len)
  1373.        byte         *p;
  1374.        unsigned int  len;
  1375.   { unsigned int  a;
  1376. --- 13,19 ----
  1377.   #include "copyright.h"
  1378.   #include "image.h"
  1379.   
  1380. ! unsigned long doMemToVal(p, len)
  1381.        byte         *p;
  1382.        unsigned int  len;
  1383.   { unsigned int  a;
  1384. ***************
  1385. *** 25,31 ****
  1386.     return(i);
  1387.   }
  1388.   
  1389. ! void valToMem(val, p, len)
  1390.        unsigned long  val;
  1391.        byte          *p;
  1392.        unsigned int   len;
  1393. --- 25,31 ----
  1394.     return(i);
  1395.   }
  1396.   
  1397. ! unsigned long doValToMem(val, p, len)
  1398.        unsigned long  val;
  1399.        byte          *p;
  1400.        unsigned int   len;
  1401. ***************
  1402. *** 35,43 ****
  1403.       *(p + a)= val & 0xff;
  1404.       val >>= 8;
  1405.     }
  1406.   }
  1407.   
  1408. ! unsigned long memToValLSB(p, len)
  1409.        byte         *p;
  1410.        unsigned int  len;
  1411.   { int val, a;
  1412. --- 35,44 ----
  1413.       *(p + a)= val & 0xff;
  1414.       val >>= 8;
  1415.     }
  1416. +   return(val);
  1417.   }
  1418.   
  1419. ! unsigned long doMemToValLSB(p, len)
  1420.        byte         *p;
  1421.        unsigned int  len;
  1422.   { int val, a;
  1423. ***************
  1424. *** 51,57 ****
  1425.   /* this is provided for orthagonality
  1426.    */
  1427.   
  1428. ! void valToMemLSB(val, p, len)
  1429.        byte          *p;
  1430.        unsigned long  val;
  1431.        unsigned int   len;
  1432. --- 52,58 ----
  1433.   /* this is provided for orthagonality
  1434.    */
  1435.   
  1436. ! unsigned long doValToMemLSB(val, p, len)
  1437.        byte          *p;
  1438.        unsigned long  val;
  1439.        unsigned int   len;
  1440. ***************
  1441. *** 60,65 ****
  1442. --- 61,67 ----
  1443.       *(p++)= val & 0xff;
  1444.       val >>= 8;
  1445.     }
  1446. +   return(val);
  1447.   }
  1448.   
  1449.   /* this flips all the bits in a byte array at byte intervals
  1450. diff -c src.2.01/window.c src.2.02/window.c
  1451. *** src.2.01/window.c    Sun Sep 30 19:04:32 1990
  1452. --- src.2.02/window.c    Sat Dec  1 20:31:55 1990
  1453. ***************
  1454. *** 13,27 ****
  1455.   #include <ctype.h>
  1456.   #include <X11/cursorfont.h>
  1457.   
  1458. - #ifdef SYSV
  1459. - #include <string.h>
  1460. - #define index strchr
  1461. - #define rindex strrchr
  1462. - #else
  1463. - char *index();
  1464. - char *rindex();
  1465. - #endif
  1466.   static Window ImageWindow= 0;
  1467.   
  1468.   static void setCursor(disp, window, iw, ih, ww, wh, cursor)
  1469. --- 13,18 ----
  1470. ***************
  1471. *** 154,160 ****
  1472.   }
  1473.   
  1474.   char imageInWindow(disp, scrn, image, user_geometry,
  1475. !            fullscreen, install, slideshow, argc, argv, verbose)
  1476.        Display      *disp;
  1477.        int           scrn;
  1478.        Image        *image;
  1479. --- 145,152 ----
  1480.   }
  1481.   
  1482.   char imageInWindow(disp, scrn, image, user_geometry,
  1483. !            fullscreen, install, private_cmap, slideshow,
  1484. !            argc, argv, verbose)
  1485.        Display      *disp;
  1486.        int           scrn;
  1487.        Image        *image;
  1488. ***************
  1489. *** 161,166 ****
  1490. --- 153,159 ----
  1491.        char         *user_geometry;
  1492.        unsigned int  fullscreen;
  1493.        unsigned int  install;
  1494. +      unsigned int  private_cmap;
  1495.        unsigned int  slideshow;
  1496.        int           argc;
  1497.        char         *argv[];
  1498. ***************
  1499. *** 221,227 ****
  1500.     }
  1501.   
  1502.     if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn),
  1503. !              image, &pixmap, &xcmap, verbose))
  1504.       exit(1);
  1505.   
  1506.     swa.background_pixel= BlackPixel(disp,scrn);
  1507. --- 214,220 ----
  1508.     }
  1509.   
  1510.     if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn),
  1511. !              image, &pixmap, &xcmap, private_cmap, verbose))
  1512.       exit(1);
  1513.   
  1514.     swa.background_pixel= BlackPixel(disp,scrn);
  1515. ***************
  1516. *** 241,247 ****
  1517.                      InputOutput, CopyFromParent,
  1518.                      CWBackPixel | CWBackingStore |
  1519.                      CWBitGravity | CWCursor | CWColormap |
  1520. !                    CWEventMask | CWSaveUnder, &swa);
  1521.       XSetCommand(disp, ImageWindow, argv, argc);
  1522.       classHint.res_class = "Xloadimage";
  1523.       classHint.res_name=NULL;
  1524. --- 234,241 ----
  1525.                      InputOutput, CopyFromParent,
  1526.                      CWBackPixel | CWBackingStore |
  1527.                      CWBitGravity | CWCursor | CWColormap |
  1528. !                    CWEventMask | CWSaveUnder |
  1529. !                    CWOverrideRedirect, &swa);
  1530.       XSetCommand(disp, ImageWindow, argv, argc);
  1531.       classHint.res_class = "Xloadimage";
  1532.       classHint.res_name=NULL;
  1533. ***************
  1534. *** 294,302 ****
  1535. --- 288,302 ----
  1536.     XMapWindow(disp, ImageWindow);
  1537.     placeImage(image->width, image->height, winwidth, winheight, &pixx, &pixy);
  1538.     if (paint) {
  1539. + #if 0
  1540. +     /* this will happen on ConfigureNotify; we avoid it here to keep from
  1541. +      * doing a double paint.
  1542. +      */
  1543.       blitImage(disp, pixmap, ImageWindow, gc,
  1544.             pixx, pixy, image->width, image->height, winwidth, winheight,
  1545.             0, 0, winwidth, winheight);
  1546. + #endif
  1547.       XResizeWindow(disp, ImageWindow, winwidth, winheight);
  1548.       XChangeWindowAttributes(disp, ImageWindow, CWColormap, &swa);
  1549.     }
  1550. ***************
  1551. *** 393,404 ****
  1552.         setCursor(disp, ImageWindow, image->width, image->height,
  1553.           winwidth, winheight, &(swa.cursor));
  1554.   
  1555. !       /* repaint 
  1556.          */
  1557.   
  1558. !       blitImage(disp, pixmap, ImageWindow, gc,
  1559. !         pixx, pixy, image->width, image->height, winwidth, winheight,
  1560. !         0, 0, winwidth, winheight);
  1561.         break;
  1562.   
  1563.       case DestroyNotify:
  1564. --- 393,405 ----
  1565.         setCursor(disp, ImageWindow, image->width, image->height,
  1566.           winwidth, winheight, &(swa.cursor));
  1567.   
  1568. !       /* repaint if we just changed images
  1569.          */
  1570.   
  1571. !       if (paint)
  1572. !     blitImage(disp, pixmap, ImageWindow, gc,
  1573. !           pixx, pixy, image->width, image->height, winwidth, winheight,
  1574. !           0, 0, winwidth, winheight);
  1575.         break;
  1576.   
  1577.       case DestroyNotify:
  1578. diff -c src.2.01/xloadimage.c src.2.02/xloadimage.c
  1579. *** src.2.01/xloadimage.c    Sun Sep 30 19:04:33 1990
  1580. --- src.2.02/xloadimage.c    Sun Dec  2 13:17:06 1990
  1581. ***************
  1582. *** 1,4 ****
  1583. ! /* loadimage.c:
  1584.    *
  1585.    * generic image loader for X11
  1586.    *
  1587. --- 1,4 ----
  1588. ! /* xloadimage.c:
  1589.    *
  1590.    * generic image loader for X11
  1591.    *
  1592. ***************
  1593. *** 21,26 ****
  1594. --- 21,27 ----
  1595.   char *Options[] = {
  1596.     "onroot", /* global options */
  1597.     "border",
  1598. +   "default",
  1599.     "display",
  1600.     "fullscreen",
  1601.     "geometry",
  1602. ***************
  1603. *** 29,34 ****
  1604. --- 30,36 ----
  1605.     "list",
  1606.     "install",
  1607.     "path",
  1608. +   "private",
  1609.     "quiet",
  1610.     "slideshow",
  1611.     "supported",
  1612. ***************
  1613. *** 39,52 ****
  1614.     "at", /* image options */
  1615.     "background",
  1616.     "brighten",
  1617. -   "gamma",
  1618.     "center",
  1619.     "clip",
  1620.     "colors",
  1621.     "dither",
  1622.     "foreground",
  1623.     "halftone",
  1624.     "name",
  1625.     "rotate",
  1626.     "smooth",
  1627.     "xzoom",
  1628. --- 41,57 ----
  1629.     "at", /* image options */
  1630.     "background",
  1631.     "brighten",
  1632.     "center",
  1633.     "clip",
  1634.     "colors",
  1635.     "dither",
  1636.     "foreground",
  1637. +   "gamma",
  1638. +   "gray",
  1639. +   "grey",
  1640.     "halftone",
  1641.     "name",
  1642. +   "normalize",
  1643.     "rotate",
  1644.     "smooth",
  1645.     "xzoom",
  1646. ***************
  1647. *** 60,73 ****
  1648.     /* global options
  1649.      */
  1650.   
  1651. !   ONROOT= 0, BORDER, DISPLAY, FULLSCREEN, GEOMETRY, HELP, IDENTIFY, LIST,
  1652. !   INSTALL, PATH, QUIET, SLIDESHOW, SUPPORTED, VERBOSE, VER_NUM, VIEW,
  1653.   
  1654.     /* local options
  1655.      */
  1656.   
  1657. !   AT, BACKGROUND, BRIGHT, GAMMA, CENTER, CLIP, COLORS, DITHER, FOREGROUND,
  1658. !   HALFTONE, NAME, ROTATE, SMOOTH, XZOOM, YZOOM, ZOOM
  1659.   };
  1660.   
  1661.   /* if an image loader needs to have our display and screen, it will get
  1662. --- 65,80 ----
  1663.     /* global options
  1664.      */
  1665.   
  1666. !   ONROOT= 0, BORDER, DEFAULT, DISPLAY, FULLSCREEN, GEOMETRY, HELP,
  1667. !   IDENTIFY, LIST, INSTALL, PATH, PRIVATE, QUIET, SLIDESHOW, SUPPORTED,
  1668. !   VERBOSE, VER_NUM, VIEW,
  1669.   
  1670.     /* local options
  1671.      */
  1672.   
  1673. !   AT, BACKGROUND, BRIGHT, CENTER, CLIP, COLORS, DITHER, FOREGROUND,
  1674. !   GAMMA, GRAY, GREY, HALFTONE, NAME, NORMALIZE, ROTATE, SMOOTH,
  1675. !   XZOOM, YZOOM, ZOOM
  1676.   };
  1677.   
  1678.   /* if an image loader needs to have our display and screen, it will get
  1679. ***************
  1680. *** 78,83 ****
  1681. --- 85,100 ----
  1682.   Display *Disp= NULL;
  1683.   int      Scrn= 0;
  1684.   
  1685. + /* used for the -default option.  this is the root weave bitmap with
  1686. +  * the bits in the order that xloadimage likes.
  1687. +  */
  1688. + #define root_weave_width 4
  1689. + #define root_weave_height 4
  1690. + static byte root_weave_bits[] = {
  1691. +   0xe0, 0xb0, 0xd0, 0x70
  1692. + };
  1693.   /* the real thing
  1694.    */
  1695.   
  1696. ***************
  1697. *** 88,95 ****
  1698. --- 105,114 ----
  1699.     char         *dname;
  1700.     unsigned int  identify;
  1701.     unsigned int  install;
  1702. +   unsigned int  private_cmap;
  1703.     unsigned int  slideshow;
  1704.     unsigned int  verbose;
  1705. +   unsigned int  set_default;
  1706.     Image        *dispimage;      /* image that will be sent to the display */
  1707.     Image        *newimage;       /* new image we're loading */
  1708.     Display      *disp;           /* display we're sending to */
  1709. ***************
  1710. *** 104,109 ****
  1711. --- 123,129 ----
  1712.     unsigned int  slide_colors= 0; /* images when in -slideshow mode */
  1713.     unsigned int  slide_dither= 0;
  1714.     float         slide_gamma= 1.0;
  1715. +   unsigned int  slide_normalize= 0;
  1716.     unsigned int  slide_smooth= 0;
  1717.     unsigned int  slide_xzoom= 0;
  1718.     unsigned int  slide_yzoom= 0;
  1719. ***************
  1720. *** 131,136 ****
  1721. --- 151,158 ----
  1722.     fullscreen= 0;
  1723.     identify= 0;
  1724.     install= 0;
  1725. +   private_cmap= 0;
  1726. +   set_default= 0;
  1727.     slideshow= 0;
  1728.     user_geometry = NULL;
  1729.     winwidth= winheight= 0;
  1730. ***************
  1731. *** 140,145 ****
  1732. --- 162,168 ----
  1733.       images[a].name= NULL;
  1734.       images[a].atx= images[a].aty= 0;
  1735.       images[a].bright= 0;
  1736. +     images[a].normalize= 0;
  1737.       images[a].gamma= 1.0;
  1738.       images[a].center= 0;
  1739.       images[a].clipx= images[a].clipy= 0;
  1740. ***************
  1741. *** 165,170 ****
  1742. --- 188,194 ----
  1743.       images[imagecount++].name= argv[a];
  1744.       if (slideshow && (imagecount < MAXIMAGES)) {
  1745.         images[imagecount].bright= slide_bright;
  1746. +       images[imagecount].normalize= slide_normalize;
  1747.         images[imagecount].gamma= slide_gamma;
  1748.         images[imagecount].dither= slide_dither;
  1749.         images[imagecount].colors= slide_colors;
  1750. ***************
  1751. *** 192,197 ****
  1752. --- 216,225 ----
  1753.       border= argv[a];
  1754.         break;
  1755.   
  1756. +     case DEFAULT:
  1757. +       set_default= 1;
  1758. +       break;
  1759.       case DISPLAY:
  1760.         if (argv[++a])
  1761.       dname= argv[a];
  1762. ***************
  1763. *** 226,231 ****
  1764. --- 254,263 ----
  1765.         showPath();
  1766.         break;
  1767.   
  1768. +     case PRIVATE:
  1769. +       private_cmap= 1;
  1770. +       break;
  1771.       case QUIET:
  1772.         verbose= 0;
  1773.         break;
  1774. ***************
  1775. *** 270,275 ****
  1776. --- 302,313 ----
  1777.       images[imagecount].bg= argv[a];
  1778.         break;
  1779.   
  1780. +     case NORMALIZE:
  1781. +       images[imagecount].normalize= 1;
  1782. +       if (slideshow)
  1783. +     slide_normalize= images[imagecount].normalize;
  1784. +       break;
  1785.       case BRIGHT:
  1786.         if (argv[++a]) {
  1787.       images[imagecount].bright= atoi(argv[a]);
  1788. ***************
  1789. *** 286,291 ****
  1790. --- 324,334 ----
  1791.         }
  1792.         break;
  1793.   
  1794. +     case GRAY:
  1795. +     case GREY:
  1796. +       images[imagecount].gray= 1;
  1797. +       break;
  1798.       case CENTER:
  1799.         images[imagecount].center= 1;
  1800.         break;
  1801. ***************
  1802. *** 410,416 ****
  1803.       }
  1804.     }
  1805.   
  1806. !   if (!imagecount) /* NO-OP from here on */
  1807.       exit(0);
  1808.   
  1809.     if (identify) {                    /* identify the named image(s) */
  1810. --- 453,459 ----
  1811.       }
  1812.     }
  1813.   
  1814. !   if (!imagecount && !set_default) /* NO-OP from here on */
  1815.       exit(0);
  1816.   
  1817.     if (identify) {                    /* identify the named image(s) */
  1818. ***************
  1819. *** 439,444 ****
  1820. --- 482,504 ----
  1821.     Scrn= scrn= DefaultScreen(disp);
  1822.     XSetIOErrorHandler(ioErrorHandler);
  1823.   
  1824. +   /* handle -default option.  this resets the colormap and loads the
  1825. +    * default root weave.
  1826. +    */
  1827. +   if (set_default) {
  1828. +     byte *old_data;
  1829. +     dispimage= newBitImage(root_weave_width, root_weave_height);
  1830. +     old_data= dispimage->data;
  1831. +     dispimage->data= root_weave_bits;
  1832. +     imageOnRoot(disp, scrn, dispimage, 0);
  1833. +     dispimage->data= old_data;
  1834. +     freeImage(dispimage);
  1835. +     if (!imagecount) /* all done */
  1836. +       exit(0);
  1837. +   }
  1838.     dispimage= NULL;
  1839.   
  1840.     if (onroot && (winwidth || winheight || images[0].center ||
  1841. ***************
  1842. *** 505,512 ****
  1843.         dispimage= newimage;
  1844.       if (slideshow) {
  1845.         switch(imageInWindow(disp, scrn, dispimage, user_geometry,
  1846. !                fullscreen, install, slideshow, argc, argv,
  1847. !                verbose)) {
  1848.         case '\0': /* window got nuked by someone */
  1849.       XCloseDisplay(disp);
  1850.       exit(1);
  1851. --- 565,572 ----
  1852.         dispimage= newimage;
  1853.       if (slideshow) {
  1854.         switch(imageInWindow(disp, scrn, dispimage, user_geometry,
  1855. !                fullscreen, install, private_cmap, slideshow,
  1856. !                argc, argv, verbose)) {
  1857.         case '\0': /* window got nuked by someone */
  1858.       XCloseDisplay(disp);
  1859.       exit(1);
  1860. ***************
  1861. *** 539,545 ****
  1862.     else {
  1863.       if (!slideshow)
  1864.         imageInWindow(disp, scrn, dispimage, user_geometry,
  1865. !             fullscreen, install, slideshow, argc, argv, verbose);
  1866.       cleanUpWindow(disp);
  1867.     }
  1868.     XCloseDisplay(disp);
  1869. --- 599,606 ----
  1870.     else {
  1871.       if (!slideshow)
  1872.         imageInWindow(disp, scrn, dispimage, user_geometry,
  1873. !             fullscreen, install, private_cmap, slideshow,
  1874. !             argc, argv, verbose);
  1875.       cleanUpWindow(disp);
  1876.     }
  1877.     XCloseDisplay(disp);
  1878. diff -c src.2.01/xloadimage.h src.2.02/xloadimage.h
  1879. *** src.2.01/xloadimage.h    Sun Sep 30 19:04:15 1990
  1880. --- src.2.02/xloadimage.h    Sun Dec  2 11:28:39 1990
  1881. ***************
  1882. *** 12,17 ****
  1883. --- 12,30 ----
  1884.   #include <X11/Xlib.h>
  1885.   #include <X11/Xutil.h>
  1886.   
  1887. + #ifdef SYSV
  1888. + #include <string.h>
  1889. + #ifndef index /* some SysV's do this for you */
  1890. + #define index strchr
  1891. + #endif
  1892. + #ifndef rindex
  1893. + #define rindex strrchr
  1894. + #endif
  1895. + #else
  1896. + char *index();
  1897. + char *rindex();
  1898. + #endif
  1899.   #include "image.h"
  1900.   #include "options.h"
  1901.   
  1902. ***************
  1903. *** 27,36 ****
  1904. --- 40,53 ----
  1905.     unsigned int  clipx, clipy; /* area of image to be used */
  1906.     unsigned int  clipw, cliph;
  1907.     unsigned int  dither;       /* true if image is to be dithered */
  1908. +   unsigned int  equalize;     /* true if image is to be equalized */
  1909. +   unsigned int  gray;         /* true if image is to be grayed */
  1910. +   unsigned int  normalize;    /* true if image is to be normalized */
  1911.     unsigned int  colors;       /* max # of colors to use for this image */
  1912.     int           rotate;          /* # degrees to rotate image */
  1913.     unsigned int  smooth;       /* true if image is to be smoothed */
  1914.     char         *fg, *bg;      /* foreground/background colors if mono image */
  1915. +   unsigned int  force;        /* true if we should force alloc of new cmap */
  1916.     unsigned int  xzoom, yzoom; /* zoom percentages */
  1917.   } ImageOptions;
  1918.   
  1919. diff -c src.2.01/xloadimage.man src.2.02/xloadimage.man
  1920. *** src.2.01/xloadimage.man    Sun Sep 30 19:04:33 1990
  1921. --- src.2.02/xloadimage.man    Sun Dec  2 14:04:56 1990
  1922. ***************
  1923. *** 59,64 ****
  1924. --- 59,68 ----
  1925.   This sets the background portion of the window which is not covered by
  1926.   any images to be \fIcolor\fR.
  1927.   .TP
  1928. + -default
  1929. + Set the root background to the default root weave.  This is the same
  1930. + as \fIxsetroot\fR with no arguments.
  1931. + .TP
  1932.   -display \fIdisplay_name\fR
  1933.   X11 display name to send the image(s) to.
  1934.   .TP
  1935. ***************
  1936. *** 91,97 ****
  1937.   Load image(s) onto the root window instead of viewing in a window.
  1938.   This is the opposite of \fI-view\fR.  \fIXSetbg\fR has this option set
  1939.   by default.  Loading with the -onroot option will fail if enough
  1940. ! sharable colors cannot be allocated from the default colormap.
  1941.   .TP
  1942.   -path
  1943.   Displays the image path and image suffixes which will be used when
  1944. --- 95,103 ----
  1945.   Load image(s) onto the root window instead of viewing in a window.
  1946.   This is the opposite of \fI-view\fR.  \fIXSetbg\fR has this option set
  1947.   by default.  Loading with the -onroot option will fail if enough
  1948. ! sharable colors cannot be allocated from the default colormap.  The
  1949. ! Hewlett-Packard version 2 server will not work correctly with this
  1950. ! option if you are loading a color image.  See \fIBUGS\fR below.
  1951.   .TP
  1952.   -path
  1953.   Displays the image path and image suffixes which will be used when
  1954. ***************
  1955. *** 98,103 ****
  1956. --- 104,115 ----
  1957.   looking for images.  These are loaded from ~/.xloadimagerc and
  1958.   optionally from a systemwide file (normally /usr/lib/xloadimagerc).
  1959.   .TP
  1960. + -private
  1961. + Force the use of a private colormap.  Normally colors are allocated
  1962. + shared unless there are not enough colors available.  This option is
  1963. + always on for the Hewlett-Packard version 2 server due to a server
  1964. + bug.  This flag is ignored if used in conjuntion with -onroot.
  1965. + .TP
  1966.   -quiet
  1967.   Forces \fIxloadimage\fR and \fIxview\fR to be quiet.  This is the
  1968.   default for \fIxsetbg\fR, but the others like to whistle. 
  1969. ***************
  1970. *** 152,161 ****
  1971.   the first image, and the \fI-onroot\fR option is specified, the image
  1972.   will be centered on the display background. 
  1973.   .TP
  1974. - -colors \fIn\fR
  1975. - Specify the maximum number of colors to use in the image.  This is a
  1976. - way to forcibly reduce the depth of an image.
  1977. - .TP
  1978.   -clip \fIX\fR,\fIY\fR,\fIW\fR,\fIH\fR
  1979.   Clip the image before loading it.  \fIX\fR and \fIY\fR define the
  1980.   upper-left corner of the clip area, and \fIW\fR and \fIH\fR define the
  1981. --- 164,169 ----
  1982. ***************
  1983. *** 162,167 ****
  1984. --- 170,179 ----
  1985.   extents of the area.  A zero value for \fIW\fR or \fIH\fR will be
  1986.   interpreted as the remainder of the image. 
  1987.   .TP
  1988. + -colors \fIn\fR
  1989. + Specify the maximum number of colors to use in the image.  This is a
  1990. + way to forcibly reduce the depth of an image.
  1991. + .TP
  1992.   -dither
  1993.   Dither a color image to monochrome using a Floyd-Steinberg dithering
  1994.   algorithm.  This happens by default when viewing color images on a
  1995. ***************
  1996. *** 178,183 ****
  1997. --- 190,200 ----
  1998.   Specify the gamma correction for the display.
  1999.   The default value is 1.0, a typical display needs 2.0 to 2.5.
  2000.   .TP
  2001. + -gray
  2002. + Convert an image to grayscale.  This is very useful when displaying
  2003. + colorful images on servers with limited color capability.  The
  2004. + optional spelling \fI-grey\fR may also be used.
  2005. + .TP
  2006.   -halftone
  2007.   Force halftone dithering of a color image when displaying on a
  2008.   monochrome display.  This option is ignored on monochrome images.
  2009. ***************
  2010. *** 189,194 ****
  2011. --- 206,214 ----
  2012.   Force the next argument to be treated as an image name.  This is
  2013.   useful if the name of the image is \fI-dither\fR, for instance. 
  2014.   .TP
  2015. + -normalize
  2016. + Normalize a color image.
  2017. + .TP
  2018.   -rotate \fIdegrees\fR
  2019.   Rotate the image by \fIdegrees\fR clockwise.  The number must be a
  2020.   multiple of 90.
  2021. ***************
  2022. *** 260,270 ****
  2023.   change the aspect ratio of an image before display.  If you use these
  2024.   options, it is recommended that you increase the size of one of the
  2025.   dimensions instead of shrinking the other, since shrinking looses
  2026. ! detail.  For instance, many GIF images have an X:Y ratio of about 2:1.
  2027. ! You can correct this for viewing on a 1:1 display with either
  2028. ! \fI-xzoom 50\fR or \fI-yzoom 200\fR (reduce X axis to 50% of its size
  2029. ! and expand Y axis to 200% of its size, respectively) but the latter
  2030. ! should be used so no detail is lost in the conversion.
  2031.   .PP
  2032.   When zooming color images up you can reduce blockiness with
  2033.   \fI-smooth\fR.  For zooms of 300% or more, I recommend two smoothing
  2034. --- 280,290 ----
  2035.   change the aspect ratio of an image before display.  If you use these
  2036.   options, it is recommended that you increase the size of one of the
  2037.   dimensions instead of shrinking the other, since shrinking looses
  2038. ! detail.  For instance, many GIF and G3 FAX images have an X:Y ratio of
  2039. ! about 2:1.  You can correct this for viewing on a 1:1 display with
  2040. ! either \fI-xzoom 50\fR or \fI-yzoom 200\fR (reduce X axis to 50% of
  2041. ! its size and expand Y axis to 200% of its size, respectively) but the
  2042. ! latter should be used so no detail is lost in the conversion.
  2043.   .PP
  2044.   When zooming color images up you can reduce blockiness with
  2045.   \fI-smooth\fR.  For zooms of 300% or more, I recommend two smoothing
  2046. ***************
  2047. *** 307,312 ****
  2048. --- 327,335 ----
  2049.   white background (which is standard), use \fI-foreground white
  2050.   -background black\fR.  This will work on both color and monochrome
  2051.   displays.
  2052. + .PP
  2053. + If you're using a display with a small colormap to display colorful
  2054. + images, try using the \fI-gray\fR option to convert to grayscale.
  2055.   .SH PATHS AND EXTENSIONS
  2056.   The file ~/.xloadimagerc (and optionally a system-wide file) defines
  2057.   the path and default extensions that \fIxloadimage\fR will use when
  2058. ***************
  2059. *** 435,437 ****
  2060. --- 458,466 ----
  2061.   Wherever possible I tried to order operations in such a way as to look
  2062.   the best possible (zooming before dithering, for instance) or to
  2063.   increase speed (zooming downward before compressing, for instance).
  2064. + .PP
  2065. + The Hewlett-Packard release 2 server supplied with HP 9000/300
  2066. + machines has a bug in XAllocColor where an allocation will not work
  2067. + correctly for the default colormap.  To work around this,
  2068. + \fIxloadimage\fR forces the -private option on for this server.  This
  2069. + bug also results in the failure of -onroot for any color image.
  2070. diff -c src.2.01/xwd.c src.2.02/xwd.c
  2071. *** src.2.01/xwd.c    Sun Sep 30 19:04:34 1990
  2072. --- src.2.02/xwd.c    Thu Nov 15 17:08:53 1990
  2073. ***************
  2074. *** 176,184 ****
  2075.     xunits--; /* we want to use one less than the actual # of units */
  2076.     shift= (unit - trailer) * 8;
  2077.     if (header.byte_order == MSBFirst)
  2078. !     loader= memToVal;
  2079.     else
  2080. !     loader= memToValLSB;
  2081.     line= (byte *)lmalloc(dlinelen);
  2082.   
  2083.     for (y= 0; y < header.pixmap_height; y++) {
  2084. --- 176,184 ----
  2085.     xunits--; /* we want to use one less than the actual # of units */
  2086.     shift= (unit - trailer) * 8;
  2087.     if (header.byte_order == MSBFirst)
  2088. !     loader= doMemToVal;
  2089.     else
  2090. !     loader= doMemToValLSB;
  2091.     line= (byte *)lmalloc(dlinelen);
  2092.   
  2093.     for (y= 0; y < header.pixmap_height; y++) {
  2094. ***************
  2095. *** 253,261 ****
  2096.     xunits= (header.pixmap_width / (unit * 8)) +
  2097.       (header.pixmap_width % (unit * 8) ? 1 : 0);
  2098.     if (header.byte_order == MSBFirst)
  2099. !     loader= memToVal;
  2100.     else
  2101. !     loader= memToValLSB;
  2102.     line= (byte *)lmalloc(dlinelen);
  2103.   
  2104.     /* for each plane, load in the bitmap and or it into the image
  2105. --- 253,261 ----
  2106.     xunits= (header.pixmap_width / (unit * 8)) +
  2107.       (header.pixmap_width % (unit * 8) ? 1 : 0);
  2108.     if (header.byte_order == MSBFirst)
  2109. !     loader= doMemToVal;
  2110.     else
  2111. !     loader= doMemToValLSB;
  2112.     line= (byte *)lmalloc(dlinelen);
  2113.   
  2114.     /* for each plane, load in the bitmap and or it into the image
  2115. ***************
  2116. *** 342,350 ****
  2117.       dlinelen= depth * header.pixmap_width;
  2118.     ilinelen= image->width * image->pixlen;
  2119.     if (header.byte_order == MSBFirst)
  2120. !     loader= memToVal;
  2121.     else
  2122. !     loader= memToValLSB;
  2123.   
  2124.     line= (byte *)lmalloc(dlinelen);
  2125.   
  2126. --- 342,350 ----
  2127.       dlinelen= depth * header.pixmap_width;
  2128.     ilinelen= image->width * image->pixlen;
  2129.     if (header.byte_order == MSBFirst)
  2130. !     loader= doMemToVal;
  2131.     else
  2132. !     loader= doMemToValLSB;
  2133.   
  2134.     line= (byte *)lmalloc(dlinelen);
  2135.   
  2136. ***************
  2137. *** 488,496 ****
  2138.   
  2139.     image->rgb.used= header.ncolors;
  2140.     for (a= 0; a < header.ncolors; a++) {
  2141. !     image->rgb.red[a]= memToVal(cmap[a].red, 2);
  2142. !     image->rgb.green[a]= memToVal(cmap[a].green, 2);
  2143. !     image->rgb.blue[a]= memToVal(cmap[a].blue, 2);
  2144.     }
  2145.   
  2146.     lfree(cmap);
  2147. --- 488,496 ----
  2148.   
  2149.     image->rgb.used= header.ncolors;
  2150.     for (a= 0; a < header.ncolors; a++) {
  2151. !     image->rgb.red[memToVal(cmap[a].pixel, 4)]= memToVal(cmap[a].red, 2);
  2152. !     image->rgb.green[memToVal(cmap[a].pixel, 4)]= memToVal(cmap[a].green, 2);
  2153. !     image->rgb.blue[memToVal(cmap[a].pixel, 4)]= memToVal(cmap[a].blue, 2);
  2154.     }
  2155.   
  2156.     lfree(cmap);
  2157.  
  2158. --
  2159. dan
  2160. ----------------------------------------------------
  2161. O'Reilly && Associates   argv@sun.com / argv@ora.com
  2162. Opinions expressed reflect those of the author only.
  2163.